package cn.cjxy.session01;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.List;


@WebServlet("/demo02")
public class Demo01Servlet extends HttpServlet {
    @Override
    protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
       
        // 模拟从数据库里面查询
        List<String> mountains_01 = Arrays.asList("庐山", "黄山", "雁荡山");
        List<String> mountains_02 = Arrays.asList("东岳泰山", "西岳华山", "南岳衡山", "北岳恒山", "中岳嵩山");

        response.setContentType("text/html;charset=utf8");
        PrintWriter out = response.getWriter();
        out.println("  <head>\n" +
                "    <title>demo</title>\n" +
                "    <style>\n" +
                "      .s1{\n" +
                "        color:blue;\n" +
                "      }\n" +
                "      .s2{\n" +
                "        color:gold;\n" +
                "      }\n" +
                "    </style>\n" +
                "  </head>");

        out.println("<h2>三山<h2>");
        out.println("<ul class='s1'>");
        for (String mountain : mountains_01) {
            out.println("<li>" + mountain + "</li>");
        }
        out.println("</ul>");
        out.println("<hr>");


        out.println("<h2>五岳<h2>");
        out.println("<ul class='s2'>");
        for (String mountain : mountains_02) {
            out.println("<li>" + mountain + "</li>");
        }
        out.println("</ul>");
    }
}